<?php
/**
 * User: lsx
 * Date: 2017/6/2
 * Time: 10:10
 * Progress:0%
 */

namespace app\shop\controller;

use icontroller\admin\AController;
use icontroller\admin\shop\IShopGoodsVariant;
use logic\admin\shop\LShopGoodsVariant;

class ShopGoodsVariant extends AController implements IShopGoodsVariant
{
    private $logic;

    public function __construct()
    {
        parent::__construct();
        $this->logic = new LShopGoodsVariant();
    }


    public function index()
    {
        $goods_id = input('goods_id');
        $this->assign("goods_id",$goods_id);
        $this->assign('index_data_url', url("/shop/shop_goods_variant/index_data/goods_id/{$goods_id}"));
        $this->assign('add_url', url("/shop/shop_goods_variant/add/goods_id/{$goods_id}"));
        return view();
        // TODO: Implement index() method.
    }

    public function index_data()
    {
        $param = array(
            'search' => input('search'),
            'limit' => input('limit'),
            'offset' => input('offset'),
            'ordinal' => input('ordinal'),
            'order' => input('order'),
            'status' => input('status'),
            "goods_id"=>input('goods_id')
        );

        $data = $this->logic->index_data($param);
        return $data;
    }

    public function add()
    {
        $goods_id = input('goods_id');
        $this->assign("goods_id",$goods_id);
        return view();
    }

    public function insert()
    {
        $param = array(
            'name' => input('name'),
            'price' => input('price'),
            'sort' => input('sort'),
            "goods_id" => input('goods_id')
        );
        return $this->logic->logic_insert($param);
    }

    public function edit()
    {
        $id = input('id');
        $data = $this->logic->logic_edit($id);
        $this->assign('data', $data);
        return view();
    }

    public function update()
    {
        $param = array(
            'id' => input('id'),
            'name' => input('name'),
            'price' => input('price'),
            'sort' => input('sort')
        );
        return $this->logic->logic_update($param);
    }

    public function delete()
    {
        $id = input('id');
        return $this->logic->logic_delete($id);
    }

//    public function cate_tree_data(){
//        $data=$this->logic->logic_cate_treeview_data();
//        return $data;
//    }
}